# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>

pkgname='python-pycryptodome'
pkgver=3.17.0
pkgrel=2
license=('BSD')
arch=('loong64' 'x86_64')
pkgdesc="Collection of cryptographic algorithms and protocols, implemented for use from Python 3."
url='https://www.pycryptodome.org/'
depends=('python' 'gmp')
makedepends=('gmp' 'python-'{build,installer,wheel} 'python-setuptools')
conflicts=('python-crypto')
provides=('python-crypto')
replaces=('python-crypto')
source=("pycryptodome-${pkgver}.tar.gz::https://github.com/Legrandin/pycryptodome/archive/v${pkgver}.tar.gz")
sha512sums=('c0a0754c0dd1d8138e8dd27c034e3f3469237eb5f205d86d0c5e2377fd7672c6ed0df9717292a73d380daaabe88c3be80b575ca1149f4c70f08d82aed0d4b39c')

build() {
  cd "$srcdir/pycryptodome-$pkgver"
  python -m build -wn
}

check() {
  cd "$srcdir/pycryptodome-$pkgver"
  python -m unittest discover
}

package() {
  cd "pycryptodome-$pkgver"
  python -m installer -d "$pkgdir" dist/*.whl
  install -Dm644 LICENSE.rst "$pkgdir/usr/share/licenses/$pkgname/LICENSE.rst"

  rm -r "$pkgdir"/usr/lib/python3.*/site-packages/Crypto/SelfTest/
}
